<?php
	/**
	*Author 雷日锦 362606856@qq.com 
	*控制器自动生成
	*/
	if(!defined("ROOT_PATH")) exit("die Access ");
	class ymdian_order_commentControl extends skymvc{
		
		public function __construct(){
			parent::__construct();
		}
		
		public function onDefault(){
			$where=" siteid=".SITEID;
			$url=APPADMIN."?m=ymdian_order_comment&a=default";
			$limit=20;
			$start=get("per_page","i");
			$option=array(
				"start"=>intval(get_post('per_page')),
				"limit"=>$limit,
				"order"=>" id DESC",
				"where"=>$where
			);
			$rscount=true;
			$data=M("ymdian_order_comment")->select($option,$rscount);
			$pagelist=$this->pagelist($rscount,$limit,$url);
			if($data){
				foreach($data as $v){
					$shopids[]=$v['shopid'];
				}
				$shops=M("ymdian")->getShopByIds($shopids);
				foreach($data as $k=>$v){
					$v['shop_name']=$shops[$v['shopid']]['title'];
					$data[$k]=$v;
				}
				
			}
			$this->smarty->assign(
				array(
					"data"=>$data,
					"pagelist"=>$pagelist,
					"rscount"=>$rscount,
					"url"=>$url
				)
			);
			$this->smarty->display("ymdian_order_comment/index.html");
		}
		
		public function onSHow(){
			 $id=get('id','i');
			 $data=M("ymdian_order_comment")->selectRow("id=".$id);
			 if($data){
				 $shop=M("ymdian")->selectRow("id=".$data['shopid']);
				 $order=M("ymdian_order")->selectRow("order_id=".$data['order_id']);
			 }
			 $this->smarty->assign(array(
			 	"data"=>$data,
				"shop"=>$shop,
				"order"=>$order
			 ));
			 $this->smarty->display("ymdian_order_comment/show.html");
		}
		
		public function onreplySave(){
			$id=get_post('id','i');
			$reply=post('reply','h');
			M("ymdian_order_comment")->update(array(
				"reply"=>$reply
			),"id=".$id);
			$this->goAll("回复成功");
		}
		
		public function onOrderIndex(){
			$id=get_post('id','i');
			switch(get('t')){
				case '1':
					M("ymdian_order_comment")->update(array(
						"orderindex"=>time()
					),"id=".$id);
					break;
				default:
					M("ymdian_order_comment")->update(array(
						"orderindex"=>0
					),"id=".$id);
					break;
			}
			$this->goAll("操作成功");
		}
		
		public function onStatus(){
			$id=get_post('id',"i");
			$status=get_post("status","i");
			M("ymdian_order_comment")->update(array("status"=>$status),"id=$id");
			$this->goall("状态修改成功",0);
		}
		
		public function onDelete(){
			$id=get_post('id',"i");
			M("ymdian_order_comment")->delete("id=".$id);
			$this->goall("删除成功",0);
		}
		
		
	}

?>